<template>
  <a-spin :spinning="confirmLoading">
    <a-row class="top-row">
        <a-col :lg="3" :md="12" :sm="21">
          <a-form-item :colon="false" label="采购名称">
            {{ model.name }}
          </a-form-item>
        </a-col>
      <a-col :lg="3" :md="12" :sm="21">
        <a-form-item :colon="false" label="采购单号">
          {{ model.purchaseNub }}
        </a-form-item>
      </a-col>
      <a-col :lg="3" :md="12" :sm="21">
        <a-form-item :colon="false" label="采购部门">
          {{ model.procurementDepartment_dictText }}
        </a-form-item>
      </a-col>
      <a-col :lg="3" :md="12" :sm="21">
        <a-form-item :colon="false" label="采购种类">
          {{ model.typeNub }}
        </a-form-item>
      </a-col>
      <a-col :lg="3" :md="12" :sm="21">
        <a-form-item :colon="false" label="采购金额（元）">
          {{ model.money }}
        </a-form-item>
      </a-col>
      <a-col :lg="3" :md="12" :sm="21">
        <a-form-item :colon="false" label="提报人">
          {{ model.createBy_dictText }}
        </a-form-item>
      </a-col>
      <a-col :lg="3" :md="12" :sm="21">
        <a-form-item :colon="false" label="提报时间">
          {{ model.subTime }}
        </a-form-item>
      </a-col>
    </a-row>
    <a-form-model-item label="采购附件" >
      <j-upload v-model="model.attachment"  :disabled="true"></j-upload>
    </a-form-model-item>
    <a-table
      class="bpbj"
      :rowKey="id"
      :columns="bpbjColumns"
      :dataSource="bpbjDataSource"
      :pagination="false"
    >
      <template slot="name" slot-scope="text, record">

      </template>
    </a-table>

      <a-form-item :colon="false" label="审核意见">
        <a-textarea v-model="model.reason"></a-textarea>
      </a-form-item>

  </a-spin>
</template>

<script>
import {getAction, httpAction, postAction} from "@api/manage";

const bpbjColumns = [
  {
    title: '备品备件名称',
    align: "center",
    dataIndex: 'name'
  },
  {
    title: '备品备件编号',
    align: "center",
    dataIndex: 'number'
  },
  {
    title: '规格型号',
    align: "center",
    dataIndex: 'model'
  },
  {
    title: '单位',
    align: "center",
    dataIndex: 'unit_dictText'
  },
  {
    title: '采购数量',
    align: "center",
    dataIndex: 'quantity',

  },
  {
    title: '采购单价（元）',
    align: "center",
    dataIndex: 'price',

  },
]
export default {
  name: "EnePurchasingCheckForm",
  components: {},
  props: {
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false
    }
  },
  data() {
    return {
      shenpiyijian:"",
      bpbjColumns,
      bpbjDataSource: [],
      bpbjHeji:0,
      model: {},

      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      confirmLoading: false,

      url: {
          list: '/ene/enePurchasingManagement/queryEnePurchasingSparepartsByMainId',
          auditing:'/ene/enePurchasingManagement/auditing'
      }
    }
  },
  computed: {
    formDisabled() {
      return this.disabled
    }
  },
  created() {


  },
  mounted() {

  },
  methods: {
    submitForm(state){
      const that = this;
      // 触发表单验证
        this.model.state=state
          that.confirmLoading = true

          postAction(this.url.auditing,this.model).then(res => {
            if(res.success){
              that.$message.success(res.message);
              that.$emit('ok');
            }else{
              that.$message.warning(res.message);
            }
          }).finally(e=>{
            that.confirmLoading = false
          })


    },
    check(record) {
      this.model = Object.assign({}, record)
      this.visible = true
      getAction(this.url.list, {id: record.id}).then(res => {
        this.bpbjDataSource = res.result
      })
    },

  }
}
</script>

<style scoped>
.top-row {
  background: #F4F5F7;
  padding: 12px 24px;

}

.top-row /deep/ .ant-form-item {
  margin-bottom: 0;
  color: #6B778C
}

.top-row /deep/ .ant-form-item-label {
  line-height: 1;
}

.top-row /deep/ .ant-form-item-control {
  line-height: 1;
  margin-top: 10px;
}

.top-row /deep/ .ant-form-item-label > label {
  color: #6B778C
}
</style>